package com.chuck.learning.solutions;

import cn.hutool.core.lang.Console;

public class 字符串替换KMP {

    public static void main(String[] args) {
        String source="abcdefg";
        String target = "defg";
        Console.log(source.substring(1,source.length()-1));
    }
    static  boolean methodKMP(String source,String target){
        char[] str1 = source.toCharArray();
        char[] str2 = target.toCharArray();
        return  false;
    }


    static  boolean method1(String source,String target){
        char[] str1 = source.toCharArray();
        char[] str2 = target.toCharArray();

        int i  =0;
        int j=0;

        while (j<=str2.length-1&&i<=str1.length-1){

            if (str2[j] == str1[i]) {
                j++;
            } else {
                i-=j;
                j=0;
            }
            i++;
        }

        if (j == str2.length) {
            return true;
        }
        return false;
    }
}
